#include <bits/stdc++.h>
#include <regex>
#include "testlib.h"

using namespace std;

int main(int argc, char* argv[]) {
    registerValidation(argc, argv);
    int group = atoi(validator.group().c_str());
    if (group == 0) group = 1;
    ensure (group == 1 || group == 2 || group == 3);
    string s = inf.readLine();
    inf.readEof();
    ensure(s.length() <= 101);
    std::regex code("[a-z]( [a-z*/+-])*");
    ensure(regex_match(s, code));
    vector<bool> used(128);
    int opcount = 0;
    for (char c : s) {
       if (c >= 'a' && c <= 'z') {
          ensure(!used[c]);
          used[c] = true;
       } else if (c == '+' || c == '-' || c == '*' || c == '/') {
          opcount++;
       }
    }
    ensure((group == 1 && opcount <= 3) || (group == 2 && opcount <= 6) || group == 3);
    int size = 0;
    for (char c : s) {
        if (c >= 'a' && c <= 'z'){
            size++;
        } else if (c == '+' || c == '-' || c == '*' || c == '/') {
            ensure(size >= 2);
            size--;
        }
    }
    ensure (size == 1);
}
